#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N = 2e5;
const int maxn = 1e6;
typedef long long int ll;
using namespace std;
//----------------------------------------------------------------------------//
int a[77];
void solve()
{
	//al+al+1+...+ar=1/2(al+ar)*(r-l+1)
	//可知ak+2-ak+1=aK=1-ak,等差
	int n;
	sd(n);
	for (int i = 0; i < n; i++) sd(a[i]);

	int ans = n - 1;//特殊情况,让每个位相等也可以满足条件

	for (int i = 0; i < n; i++)//数据量小,直接暴力
	{
		for (int j = i + 1; j < n; j++)
		{
			int tmp = a[j] - a[i];
			int tmp2 = j - i;//相差位数
			int tmp3 = tmp2 * a[i] - tmp * i;//首项
			int cur = 0;
			for (int k = 0; k < n; k++)
			{
				int num =tmp * k + tmp3;
				if (num != tmp2 * a[k])
					cur++;
			}
			ans = min(ans, cur);
		}
	}
	pd(ans);
	puts("");
}

int main()
{
	int T;
	sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}